﻿using System;
using System.Threading.Tasks;
using FFmpegVideoClip.Configuration;

namespace FFmpegVideoClip.Lib
{
    public enum TaskSchedulerEnum { Default, CpuPerformanceLimited }
    internal class TaskSchedulerSelector
    {
        public static readonly TaskSchedulerEnum[] m_All = Enum.GetValues<TaskSchedulerEnum>();
        public static TaskSchedulerEnum[] All => m_All;

        public static TaskScheduler Get => Config.TaskScheduler switch
        {
            TaskSchedulerEnum.CpuPerformanceLimited => new LimitedParallelPerformanceTaskScheduler(Config.MaxThread, Tools.CurrentCancelToken?.Token, true, Config.CpuPerformanceLimit, Config.CpuPerformanceCountCache, Config.TaskPollingInterval, AutoCancel: true),
            _ => TaskScheduler.Default
        };
    }
}
